package org.ibase4j.system.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.ibase4j.system.model.SysNotice;
import org.ibase4j.system.service.SysNoticeService;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import top.ibase4j.core.base.BaseController;

import java.util.Map;

/**
 * 通知管理控制类
 *
 * @author ShenHuaJie
 * @version 2016年5月20日 下午3:13:31
 */
@RestController
@Api(value = "通知管理", description = "通知管理")
@RequestMapping(value = "notice")
public class SysNoticeController extends BaseController<SysNotice, SysNoticeService> {
    @Override
    @ApiOperation(value = "查询通知")
    @RequiresPermissions("cms.notice.read")
    @PostMapping(value = "/read/page")
    public Object query(ModelMap modelMap, @RequestBody Map<String, Object> param) {
        return super.query(modelMap, param);
    }

    @ApiOperation(value = "通知详情")
    @RequiresPermissions("cms.notice.read")
    @RequestMapping(value = "/read/detail", method = RequestMethod.PUT)
    public Object get(ModelMap modelMap, @RequestBody SysNotice param) {
        return super.get(modelMap, param);
    }

    @Override
    @ApiOperation(value = "修改通知")
    @RequiresPermissions("cms.notice.update")
    @PostMapping(value = "/save")
    public Object update(ModelMap modelMap, @RequestBody SysNotice param) {
        if (param.getStatus() == null) {
            param.setStatus("0");
        }
        return super.update(modelMap, param);
    }

    @Override
    @ApiOperation(value = "删除通知")
    @RequiresPermissions("cms.notice.delete")
    @PostMapping(value = "/delete")
    public Object delete(ModelMap modelMap, @RequestBody SysNotice param) {
        return super.delete(modelMap, param);
    }
}
